import { isUrl } from './is'

// 路由
export const pathResolve = (parentPath, path) => {
  if (isUrl(path)) return path
  const childPath = path.startsWith('/') || !path ? path : `/${path}`
  return `${parentPath}${childPath}`.replace(/\/\//g, '/')
}

// 是否是number类型
export const isNumber = (value) => {
  return typeof value === 'number' && isFinite(value)
}
// 是否是Number 处理成Css PX
export const toCssPx = (value) => {
  if (isNumber(Number(value))) {
    return `${value}px`
  }
  return value
}
